/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/18 17:31
  *
  * @file       pd_adc.h
  * @brief      Header file of ADC peripheral driver.
  *
  * @note       This file contains the ADC object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/18     Chris        the first version
  *
  ******************************************************************************
  */


#ifndef JLC_SKY_ADC_H
#define JLC_SKY_ADC_H

#include "pd_gpio.h"
#include "pd_adc_ch.h"

struct ADCBaseVtbl;

/** @defgroup Object properties
  * @{
  */
typedef struct {
    ADC_TypeDef *ADCx;
    ADCChannel *adcChannel;

    uint32_t Resolution;
    uint32_t DataAlignment;
    uint32_t SequencersScanMode; // ADC scan mode(ADC_CR1_SCAN, Bit 8)

    uint32_t CommonClock;
#if defined(ADC_MULTIMODE_SUPPORT)
    uint32_t Multimode;
    uint32_t MultiDMATransfer;
    uint32_t MultiTwoSamplingDelay;
#endif /* ADC_MULTIMODE_SUPPORT */

    // ADCBase virtual table
    struct ADCBaseVtbl *vptr;
} ADCBase;
/**
 * @}
 */

/** @defgroup Object virtual table definition
  * @{
  */
struct ADCBaseVtbl {
    void (*init)(const ADCBase *this);

};
/**
 * @}
 */

/** @defgroup Object constructor and member function declaration
  * @{
  */
void ADCBase_constructor(ADCBase *this, ADC_TypeDef *ADCx, ADCChannel *adcChannel, uint32_t SequencersScanMode);
/**
 * @}
 */

/** @defgroup Object virtual table function implementation
  * @{
  */
static inline void ADCBase_init(const ADCBase *this) {
    this->vptr->init(this);
}
/**
 * @}
 */


#endif //JLC_SKY_ADC_H
